//package org.ejb.stateless;
//
//import java.util.List;
//import java.util.Set;
//import java.util.logging.Logger;
//
//import javax.ejb.Stateless;
//import javax.ejb.TransactionAttribute;
//import javax.ejb.TransactionAttributeType;
//import javax.persistence.EntityManager;
//import javax.persistence.PersistenceContext;
//import javax.persistence.Query;
//
//import org.ejb.api.ItemInterface;
//import org.ejb.entities.Item;
//import org.ejb.entities.Produit;
//import org.ejb.entities.ValidationException;
//
//@SuppressWarnings(value = "unchecked")
//@TransactionAttribute(value = TransactionAttributeType.REQUIRED)
//@Stateless(mappedName = "org.ejb.stateless.ItemStateless@Remote", description = "Item stateless", name = "ItemStateless")
//public class ItemStateless implements ItemInterface {
//	@PersistenceContext
//    private EntityManager em;
//
//    private final String cname = this.getClass().getName();
//    private Logger logger = Logger.getLogger("org.ejb.stateless");
//    
////    public void ajouteItem(Produit produit, Item item) {
////        String mname = "createItem";
////        logger.entering(cname, mname, item);
////
////        // On s'assure de la validite des paramatres
////        if (produit == null) throw new ValidationException("Produit object is null");
////        if (item == null) throw new ValidationException("Item object is null");   
//////        item.setEvals(evals);
//////        item.setEvaluation(evaluation);       
////        item.setProduit(produit);
////        em.merge(item);
////
////        logger.exiting(cname, mname, item);
////        //return item;
////    }
//    
//    
////    public Item findItem(final Long itemid) {
////        final String mname = "findItem";
////        logger.entering(cname, mname, itemid);
////
////        // On s'assure de la validite des paramatres
////        if (itemid == null)
////            throw new ValidationException("Invalid id");
////
////        Item item;
////
////        // On recherche l'objet a partir de son identifiant
////        item = em.find(Item.class, itemid);
////
////        logger.exiting(cname, mname, item);
////        return item;
////    }
////
////    public void deleteItem(final Item item) {
////        final String mname = "deleteItem";
////        logger.entering(cname, mname, item);
////
////        // On s'assure de la validite des paramatres
////        if (item == null)
////            throw new ValidationException("Item object is null");
////
////        // On supprime l'objet de la base de donnees
////        em.remove(em.merge(item));
////
////        logger.exiting(cname, mname);
////    }
////
////    public Item updateItem(final Item item, final String description, final String name, final Set<Evaluation> evals, final float evaluation, final String imagePath, final Produit product, final int soldQuantity, final Float unitCost) {
////        final String mname = "updateItem";
////        logger.entering(cname, mname, item);
////
////        // On s'assure de la validite des paramatres
////        if (item == null)
////            throw new ValidationException("Item object is null");
////
////        item.setDescription(description);
////        item.setName(name);
//////        item.setEvals(evals);
//////        item.setEvaluation(evaluation);
////        item.setImagePath(imagePath);
////        item.setProduit(product);
////        item.setSoldQuantity(soldQuantity);
////        item.setUnitCost(unitCost);
////
////        // On modifie l'objet de la base de donnees
////        em.merge(item);
////
////        logger.exiting(cname, mname, item);
////        return item;
////    }
////
////    public List<Item> findItems() {
////        final String mname = "findItems";
////        logger.entering(cname, mname);
////
////        Query query;
////        List<Item> item;
////
////        // On modifie l'objet de la base de donnees
////        query = em.createQuery("SELECT c FROM Item c");
////        item = query.getResultList();
////
////        logger.exiting(cname, mname, item.size());
////        return item;
////    }
////    
////    public List<Item> searchItems(final String keyword) {
////        final String mname = "searchItems";
////        logger.entering(cname, mname, keyword);
////
////        Query query;
////        List<Item> items;
////
////        // On modifie l'objet de la base de donnees
////        query = em.createQuery("SELECT i FROM Item i WHERE UPPER(i.name) LIKE :keyword OR UPPER(i.product.name) LIKE :keyword ORDER BY i.product.name");
////        query.setParameter("keyword", "%" + keyword.toUpperCase() + "%");
////        items = query.getResultList();
////
////        logger.exiting(cname, mname, items.size());
////        return items;
////    }
//}
